import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;

public class test1 {
    // 写一个方法用来记录后边补0

    public String su(String str){


        // 定义一个字符串用来记录后边的补位0
        StringBuilder end = new StringBuilder();
        if(str.length()<6){
            int length = 6-str.length();
            for(int i=1;i<=length;i++){
                end.append("0");
            }
        }
        return str+end;
    }

    static int sum(int n){
        int sum = 0;
        int i = 1;
        for(;i<=n;i++){
            sum = sum + i;
        }
        return sum;
    }

    public static void main(String[] args) {
        // 创建一个 HashMap
        HashMap<String, Integer> prices = new HashMap<>();

        // 往HashMap中添加映射项
        prices.put("Shoes", null);
        prices.put("Bag", 300);
        prices.put("Pant", 150);
        System.out.println("HashMap: " + prices);

        // 计算 Shirt 的值
        int shirtPrice = prices.computeIfAbsent("Shoes", key -> 280);
        System.out.println("Price of Shirt: " + shirtPrice);

        // 输出更新后的HashMap
        System.out.println("Updated HashMap: " + prices);
        System.out.println("总数:"+sum(2));
        LinkedList<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        System.out.println(list);
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);
        arrayList.add(2);
        System.out.println(arrayList);


    }
}
